import './icon/iconfont.css';
import styles from './index.module.scss';
import classNames from 'classnames';
import React from 'react';
import {checkIconIsExist} from "@/layouts/menuUtil";
// @ts-ignore
// import { createFromIconfontCN } from '@ant-design/icons';
// import scriptUrl from './icon/iconfont';
//
// console.log(11, scriptUrl);
//
// const IconFont = createFromIconfontCN({
//   scriptUrl,
// });

/**
 * 自定义icon
 * @param type
 * @param className
 * @param spin
 * @param rest
 * @return {*}
 * @constructor
 */
interface IIconFont {
  type: string;
  className?: string;
  spin?:string;
  [key: string]: any;
}
const IconFont = ({ type, className, spin, notFind, ...rest }: IIconFont) => {
  if(!checkIconIsExist(type)) {
    return notFind || '';
  }
  const classString = classNames({
    iconfont: true,
    [styles['custom-icon-spin']]: !!spin,
    [`${type}`]: true,
    // anticon: true,
  }, className);

  return <i className={classString} {...rest} />;
};

export default IconFont;
